/* 使用 React-redux 连接 React 与 Redux */
import { useDispatch, useSelector } from 'react-redux';
import { Button } from 'antd';
export default function MyDemo() {
  const dispatch = useDispatch();
  const storeState = useSelector(state => state);

  console.log('state', storeState);

  return (
    <div>
      <h2>MyDemo test</h2>
      <hr />
      <p>redux combineReducers 学习</p>
      <div>
        reducer {storeState.myName}
        <Button
          onClick={() => {
            dispatch({
              type: 'increase',
              num: 11
            });
          }}
        >
          加 reducer 值
        </Button>
      </div>
      <hr />
      <div>
        reducerTodo {JSON.stringify(storeState.reducerTodo)}
        <Button
          onClick={() => {
            dispatch({
              type: 'ADD_TODO',
              addNum: 110
            });
          }}
        >
          加 reducerTodo 值
        </Button>
      </div>
      <Button
        onClick={() => {
          console.log('查看 store 中的数据', storeState);
        }}
      >
        查看store中的数据
      </Button>
    </div>
  );
}
